package com.hmall.feign.client;

import com.hmall.feign.dto.Item;
import com.hmall.feign.dto.PageDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(value = "itemservice", path = "/item")
public interface ItemClient {

    //分页查询商品
    @GetMapping("/list")
    PageDTO<Item> itemList(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "size", defaultValue = "1") Integer size
    );

    //减少库存
    @PostMapping("/reduceItemStockNum")
    void reduceItemStockNum(@RequestParam Long itemId, @RequestParam Integer num);

    //增加库存
    @PutMapping("/returnItemStockNum/{itemId}/{num}")
    void returnItemStockNum(@PathVariable Long itemId, @PathVariable Integer num);

    //查询总条数
    @GetMapping("/count")
    int count();

    //根据id查询商品
    @GetMapping("/{id}")
    Item getItemById(@PathVariable("id") Long id);

}
